#include "../mqserver/mq_route.hpp"
#include <gtest/gtest.h>

class RouteTest:public testing::Environment
{
    public:
        virtual void SetUp() override
        {

        }

        virtual void TearDown() override
        {
            //emp->clear();
        }
};


TEST(route_test,legal_routing_key)
{
    std::string rkey1="new.music.pop";
    std::string rkey2="new..music.pop";
    std::string rkey3="new.,music.pop";
    std::string rkey4="new.music_123.pop";
    ASSERT_EQ(castlemq::Router::isLegal_RoutingKey(rkey1),true);
    ASSERT_EQ(castlemq::Router::isLegal_RoutingKey(rkey2),true);
    ASSERT_EQ(castlemq::Router::isLegal_RoutingKey(rkey3),false);
    ASSERT_EQ(castlemq::Router::isLegal_RoutingKey(rkey4),true);

}

TEST(route_test,legal_binding_key)
{
    std::string bkey1="new.music.pop";
    std::string bkey2="new.#.music.pop";
    std::string bkey3="new.#.*.music.pop";
    std::string bkey4="new.*.#.music.pop";
    std::string bkey5="new.#.#.music.pop";
    std::string bkey6="new.*.*.music.pop";
    std::string bkey7="new.,music_123.pop";
    ASSERT_EQ(castlemq::Router::isLegal_BindingKey(bkey1),true);
    ASSERT_EQ(castlemq::Router::isLegal_BindingKey(bkey2),true);
    ASSERT_EQ(castlemq::Router::isLegal_BindingKey(bkey3),false);
    ASSERT_EQ(castlemq::Router::isLegal_BindingKey(bkey4),false);
    ASSERT_EQ(castlemq::Router::isLegal_BindingKey(bkey5),false);
    ASSERT_EQ(castlemq::Router::isLegal_BindingKey(bkey6),true);
    ASSERT_EQ(castlemq::Router::isLegal_BindingKey(bkey7),false);

}

TEST(route_test,route_test)
{
    
}

int main(int argc,char* argv[])
{
    testing::InitGoogleTest(&argc,argv);
    testing::AddGlobalTestEnvironment(new RouteTest);
    RUN_ALL_TESTS();
    return 0;
}